package com.pbc.gmp.action;

import com.pbc.gmp.dao.MenuResMapper;
import com.pbc.gmp.model.basemodel.Acl;
import com.pbc.gmp.model.mybatisDto.AclTotalDto;
import com.pbc.gmp.service.IAclService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;
import java.util.Set;

/**
 * <p>
 * é‰å†®æªºéŽºÑƒåŸ—é¨å‹«å§é–¿î†¾è¢«é”›å²ƒç¹–æ¶“î†è¢«é¢ã„¦æ½µç€›æ¨ºåæ¶“è®³ç¶‹éœå²ƒç¥«å©§æ„ªç®£é—‚å¯¸æ®‘éå´‡éƒ´é”›å²€æ•¤é‰ãƒ§â€˜ç€¹æ°«å¯Œæµ£æ’¹å…˜æ¾¶ç†·î‡®éîƒç°ºç’§å‹¬ç°®æ©æ¶œî”‘éîƒç°ºéŽ¿å¶„ç¶”  前端控制器
 * </p>
 *
 * @author kjk
 * @since 2017-04-17
 */
@Controller
@RequestMapping("/acl")
public class AclController {
    @Autowired
    private IAclService aclService;
    @RequestMapping(value="/predit")
    public String predit(Model model, @RequestParam Long id) {
        model.addAttribute("id", id);
        return "admin/permission/roleGrant";
    }
    @RequestMapping(value="/grant")
    public String grant(@RequestParam(value = "resourceIds") List<Long> ids , @RequestParam(value = "id") Long roleid) {
        aclService.InsertAclsByUserId(ids ,roleid);
        return "更新成功";
    }
    @RequestMapping(value="/findResourceIdListByRoleId")
    @ResponseBody
    public Object findResourceIdListByRoleId( @RequestParam(value = "id") Long roleid) {
        List<Long> resources=aclService.selectResIdsByRoleId(roleid);
        return resources;
    }

}
